import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { IChargerStorageVo } from '@/api/system/storage/types'

enum Api {
  list = '/storage/list',
  delete = '/storage/delete',
  batchDelete = '/storage/batchDelete',
  add = '/storage/add',
  batchAdd = '/storage/batchAdd',
  edit = '/storage/edit',
  detail = '/storage/detail',
  batchStore = '/storage/batchStore',
}

// 获取列表
export const storageList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const storageDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}

// 批量删除
export const storageBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 批量生成
export const storageBatchAdd = (data: IChargerStorageVo) => {
  return request({
    url: Api.batchAdd,
    method: 'post',
    data,
  })
}

// 批量入库
export const storageBatchStore = (data: (string | number)[]) => {
  return request({
    url: Api.batchStore,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const storageSave = (data: IChargerStorageVo) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 获取设备详情
export const storageDetail = (data: IChargerStorageVo) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}
